<template>
  <view
    @click="handleSelectTimePeriod"
    :class="['main_form_time_item_small', item.isActive ? 'active' : '']"
    v-if="type === 'timePeriod'"
  >
    <view class="main_form_time_item_content">09:00-09:30</view>
    <view class="main_form_time_item_status">余2</view>
  </view>
  <view
    @click="handleSelectDate"
    :class="['main_form_time_item_large', item.isActive ? 'active' : '']"
    v-if="type === 'date'"
  >
    <view
      class="main_form_time_item_content"
      :style="{ color: item.isActive ? '#4C9CEA' : '' }"
    >
      <view class="week">周三</view>
      <view class="day">1/15</view>
    </view>
    <view class="main_form_time_item_status">余2</view>
  </view>
</template>
<script>
export default {
  name: "BookingTime",
  props: {
    type: {
      type: String,
      default: "",
    },
    item: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {};
  },
  methods: {
    //点击时间段
    handleSelectTimePeriod() {
      this.$emit("handleClick");
    },
    //点击日期
    handleSelectDate() {
      this.$emit("handleClick");
    },
  },
};
</script>
<style lang="scss" scoped>
.main_form_time_item_small {
  width: 198rpx;
  height: 120rpx;
  background: #f8fafd;
  border-radius: 8rpx;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28rpx;
  color: #181818;
  line-height: 33rpx;
  border: 2rpx solid #f8fafd;
  margin: 0 calc((100% - 202rpx * 3) / 4);
  &:nth-child(3n + 1) {
    margin-left: 0;
  }
  &:nth-child(3n) {
    margin-right: 0;
  }
  margin-bottom: 20rpx;
  .main_form_time_item_content {
    font-size: 28rpx;
    color: #181818;
    line-height: 33rpx;
    margin-top: 16rpx;
  }
  .main_form_time_item_status {
    position: absolute;
    right: 0;
    top: 0;
    width: 88rpx;
    height: 32rpx;
    background: #4c9cea;
    border-radius: 0rpx 8rpx 0rpx 8rpx;
    width: 62rpx;
    font-size: 20rpx;
    color: #ffffff;
    line-height: 23rpx;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.main_form_time_item_large {
  width: 156rpx;
  height: 120rpx;
  background: #f8fafd;
  border-radius: 8rpx;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28rpx;
  color: #181818;
  line-height: 33rpx;
  border: 2rpx solid #f8fafd;
  margin: 0 calc((100% - (160rpx * 4)) / 6);
  &:nth-child(4n + 1) {
    margin-left: 0;
  }
  &:nth-child(4n) {
    margin-right: 0;
  }
  margin-bottom: 20rpx;
  .main_form_time_item_content {
    color: #181818;
    margin-top: 20rpx;
    .week {
      font-size: 28rpx;
      line-height: 33rpx;
    }
    .day {
      font-size: 24rpx;
      line-height: 28rpx;
      margin-top: 6rpx;
    }
  }
  .main_form_time_item_status {
    position: absolute;
    right: 0;
    top: 0;
    width: 88rpx;
    height: 32rpx;
    background: #4c9cea;
    border-radius: 0rpx 8rpx 0rpx 8rpx;
    width: 62rpx;
    font-size: 20rpx;
    color: #ffffff;
    line-height: 23rpx;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.active {
  background: rgba(76, 156, 234, 0.2);
  border: 2rpx solid #4c9cea;
}
</style>
